home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / TranslationExtensions.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  6.9 KB  |  228 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        TranslationExtensions.p
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1989-1993, 1995, 1997-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT TranslationExtensions;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  28. {$SETC __TRANSLATIONEXTENSIONS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC TranslationExtensionsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MACTYPES__}
  35. {$I MacTypes.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __FILES__}
  38. {$I Files.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __QUICKDRAW__}
  41. {$I Quickdraw.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __COMPONENTS__}
  44. {$I Components.p}
  45. {$ENDC}
  46.  
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51.  
  52.  
  53. CONST
  54.     kSupportsFileTranslation    = 1;
  55.     kSupportsScrapTranslation    = 2;
  56.     kTranslatorCanGenerateFilename = 4;
  57.  
  58.  
  59. {  better names for 4-char codes }
  60.  
  61. TYPE
  62.     FileType                            = OSType;
  63.     ScrapType                            = ResType;
  64.     TranslationAttributes                = UInt32;
  65.  
  66. CONST
  67.     taDstDocNeedsResourceFork    = 1;
  68.     taDstIsAppTranslation        = 2;
  69.  
  70.  
  71.  
  72. TYPE
  73.     FileTypeSpecPtr = ^FileTypeSpec;
  74.     FileTypeSpec = RECORD
  75.         format:                    FileType;
  76.         hint:                    LONGINT;
  77.         flags:                    TranslationAttributes;                    {  taDstDocNeedsResourceFork, taDstIsAppTranslation }
  78.         catInfoType:            OSType;
  79.         catInfoCreator:            OSType;
  80.     END;
  81.  
  82.     FileTranslationListPtr = ^FileTranslationList;
  83.     FileTranslationList = RECORD
  84.         modDate:                UInt32;
  85.         groupCount:                UInt32;
  86.                                                                         {      unsigned long    group1SrcCount; }
  87.                                                                         {      unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec); }
  88.                                                                         {   FileTypeSpec    group1SrcTypes[group1SrcCount] }
  89.                                                                         {   unsigned long    group1DstCount; }
  90.                                                                         {   unsigned long    group1DstEntrySize = sizeof(FileTypeSpec); }
  91.                                                                         {   FileTypeSpec    group1DstTypes[group1DstCount] }
  92.     END;
  93.  
  94.     FileTranslationListHandle            = ^FileTranslationListPtr;
  95.  
  96.     ScrapTypeSpecPtr = ^ScrapTypeSpec;
  97.     ScrapTypeSpec = RECORD
  98.         format:                    ScrapType;
  99.         hint:                    LONGINT;
  100.     END;
  101.  
  102.     ScrapTranslationListPtr = ^ScrapTranslationList;
  103.     ScrapTranslationList = RECORD
  104.         modDate:                UInt32;
  105.         groupCount:                UInt32;
  106.                                                                         {      unsigned long        group1SrcCount; }
  107.                                                                         {      unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec); }
  108.                                                                         {   ScrapTypeSpec        group1SrcTypes[group1SrcCount] }
  109.                                                                         {   unsigned long        group1DstCount; }
  110.                                                                         {      unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec); }
  111.                                                                         {   ScrapTypeSpec        group1DstTypes[group1DstCount] }
  112.     END;
  113.  
  114.     ScrapTranslationListHandle            = ^ScrapTranslationListPtr;
  115. {  definition of callbacks to update progress dialog }
  116.     TranslationRefNum                    = LONGINT;
  117. {****************************************************************************************
  118. *
  119. * This routine sets the advertisement in the top half of the progress dialog.
  120. * It is called once at the beginning of your DoTranslateFile routine.
  121. *
  122. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  123. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  124. *                            Before returning from DoTranslateFile, you should dispose
  125. *                            of the memory.  (Normally, it is in the temp translation heap
  126. *                            so it is cleaned up for you.)
  127. *
  128. * Exit:    returns            noErr, paramErr, or memFullErr
  129. }
  130. FUNCTION SetTranslationAdvertisement(refNum: TranslationRefNum; advertisement: PicHandle): OSErr;
  131.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  132.     INLINE $7002, $ABFC;
  133.     {$ENDC}
  134.  
  135. {****************************************************************************************
  136. *
  137. * This routine updates the progress bar in the progress dialog.
  138. * It is called repeatedly from within your DoTranslateFile routine.
  139. * It should be called often, so that the user will get feedback if he tries to cancel.
  140. *
  141. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  142. *            progress    percent complete (0-100)
  143. *
  144. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  145. *            returns        noErr, paramErr, or memFullErr
  146. }
  147. FUNCTION UpdateTranslationProgress(refNum: TranslationRefNum; percentDone: INTEGER; VAR canceled: BOOLEAN): OSErr;
  148.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  149.     INLINE $7001, $ABFC;
  150.     {$ENDC}
  151.  
  152.  
  153. {  ComponentMgr selectors for routines }
  154.  
  155. CONST
  156.     kTranslateGetFileTranslationList = 0;                        {  component selectors }
  157.     kTranslateIdentifyFile        = 1;
  158.     kTranslateTranslateFile        = 2;
  159.     kTranslateGetTranslatedFilename = 3;
  160.     kTranslateGetScrapTranslationList = 10;                        {  skip to scrap routines }
  161.     kTranslateIdentifyScrap        = 11;
  162.     kTranslateTranslateScrap    = 12;
  163.  
  164.  
  165. {  Routines to implment in a file translation extension }
  166.  
  167.  
  168.  
  169. TYPE
  170. {$IFC TYPED_FUNCTION_POINTERS}
  171.     DoGetFileTranslationListProcPtr = FUNCTION(self: ComponentInstance; translationList: FileTranslationListHandle): ComponentResult;
  172. {$ELSEC}
  173.     DoGetFileTranslationListProcPtr = ProcPtr;
  174. {$ENDC}
  175.  
  176. {$IFC TYPED_FUNCTION_POINTERS}
  177.     DoIdentifyFileProcPtr = FUNCTION(self: ComponentInstance; {CONST}VAR theDocument: FSSpec; VAR docType: FileType): ComponentResult;
  178. {$ELSEC}
  179.     DoIdentifyFileProcPtr = ProcPtr;
  180. {$ENDC}
  181.  
  182. {$IFC TYPED_FUNCTION_POINTERS}
  183.     DoTranslateFileProcPtr = FUNCTION(self: ComponentInstance; refNum: TranslationRefNum; {CONST}VAR sourceDocument: FSSpec; srcType: FileType; srcTypeHint: LONGINT; {CONST}VAR dstDoc: FSSpec; dstType: FileType; dstTypeHint: LONGINT): ComponentResult;
  184. {$ELSEC}
  185.     DoTranslateFileProcPtr = ProcPtr;
  186. {$ENDC}
  187.  
  188. {$IFC TYPED_FUNCTION_POINTERS}
  189.     DoGetTranslatedFilenameProcPtr = FUNCTION(self: ComponentInstance; dstType: FileType; dstTypeHint: LONGINT; VAR theDocument: FSSpec): ComponentResult;
  190. {$ELSEC}
  191.     DoGetTranslatedFilenameProcPtr = ProcPtr;
  192. {$ENDC}
  193.  
  194.  
  195. {  Routine to implement in a scrap translation extension }
  196.  
  197. {$IFC TYPED_FUNCTION_POINTERS}
  198.     DoGetScrapTranslationListProcPtr = FUNCTION(self: ComponentInstance; list: ScrapTranslationListHandle): ComponentResult;
  199. {$ELSEC}
  200.     DoGetScrapTranslationListProcPtr = ProcPtr;
  201. {$ENDC}
  202.  
  203. {$IFC TYPED_FUNCTION_POINTERS}
  204.     DoIdentifyScrapProcPtr = FUNCTION(self: ComponentInstance; dataPtr: UNIV Ptr; dataLength: Size; VAR dataFormat: ScrapType): ComponentResult;
  205. {$ELSEC}
  206.     DoIdentifyScrapProcPtr = ProcPtr;
  207. {$ENDC}
  208.  
  209. {$IFC TYPED_FUNCTION_POINTERS}
  210.     DoTranslateScrapProcPtr = FUNCTION(self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: UNIV Ptr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: LONGINT; dstData: Handle; dstType: ScrapType; dstTypeHint: LONGINT): ComponentResult;
  211. {$ELSEC}
  212.     DoTranslateScrapProcPtr = ProcPtr;
  213. {$ENDC}
  214.  
  215.  
  216.  
  217.  
  218. {$ALIGN RESET}
  219. {$POP}
  220.  
  221. {$SETC UsingIncludes := TranslationExtensionsIncludes}
  222.  
  223. {$ENDC} {__TRANSLATIONEXTENSIONS__}
  224.  
  225. {$IFC NOT UsingIncludes}
  226.  END.
  227. {$ENDC}
  228.